<?php

declare( strict_types = 1 );

namespace App\Common\Model\Base\DataManager\MainV3;

use App\Common as com;

class ClientsInfo extends com\Cla\ClaBase {

	private com\Model\Base\DataManager $mainThis;

	/**
	 * @var string
	 */
	private string $clientName;

	/**
	 *
	 * @param com\Model\Base\DataManager $mainThis
	 * @param string $clientName Clients名
	 */
	public function __construct( com\Model\Base\DataManager $mainThis, string $clientName ) {
		$this->mainThis = $mainThis;
		$this->clientName = $clientName;
		//
		parent::__construct();
	}

	/**
	 * @return string
	 */
	public function getClientName(  ):string {
		return $this->clientName;
	}

	/**
	 * 获取 goClient 对象
	 * @return com\Model\Base\DataManager
	 */
	public function goClient(  ) {
		$clientName = 'goClient' . com\Lib\Fun\Str::parseName( $this->clientName, 1, true );
		return $this->mainThis->$clientName();
	}

	/**
	 * 调用 saveClient 保存数据
	 * @param int $mainDataId
	 * @return void
	 * @throws
	 */
	public function saveClient( int $mainDataId ):void {
		$this->mainThis->saveClient( $this->goClient(), $mainDataId );
	}

/*	public function removeGoClientPool(  ) {
		// $this->mainThis->
	}
	*/
	// ===============================
	//
	//
	// 下面为静态方法
	//
	//
	// ===============================

	public static function makeOfNew( com\Model\Base\DataManager $mainThis, string $clientName ) {
		return self::make( $mainThis, $clientName );
	}
	
}
